/**
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates.
 * The Universal Permissive License (UPL), Version 1.0
 */
"use strict";
define(["ojs/ojcore","jquery","ojs/ojcomponentcore","ojs/ojdvt-base","ojs/internal-deps/dvt/DvtThematicMap"],function(a,g,b,c,d){a.Ra("oj.ojThematicMap",g.oj.dvtBaseComponent,{widgetEventPrefix:"oj",options:{load:null,optionChange:null},f6:"",WD:[],A4:"resources/internal-deps/dvt/thematicMap/basemaps/",Xda:{ar:"ar",cs:"cs",da:"da",de:"de",el:"el",es:"es",fi:"fi",fr:"fr","fr-ca":"fr_CA",he:"iw",hu:"hu",it:"it",ja:"ja",ko:"ko",nl:"nl",no:"no",pl:"pl",pt:"pt_BR","pt-pt":"pt",ro:"ro",ru:"ru",sk:"sk",
sv:"sv",th:"th",tr:"tr","zh-hans":"zh_CN","zh-hant":"zh_TW"},_ComponentCreate:function(){this._super();this.ev=[];this.w$=!1;this.Cy=[]},Dg:function(a,b,c){return d.ThematicMap.newInstance(a,b,c)},Hk:function(a){var b=a.subId;"oj-thematicmap-area"==b?b=a.dataLayer+":area["+a.index+"]":"oj-thematicmap-marker"==b?b=a.dataLayer+":marker["+a.index+"]":"oj-thematicmap-link"==b?b=a.dataLayer+":link["+a.index+"]":"oj-thematicmap-tooltip"==b&&(b="tooltip");return b},Oh:function(a){var b={};0<a.indexOf(":area")?
(b.subId="oj-thematicmap-area",b.dataLayer=a.substring(0,a.indexOf(":")),b.index=this.Jk(a)):0<a.indexOf(":marker")?(b.subId="oj-thematicmap-marker",b.dataLayer=a.substring(0,a.indexOf(":")),b.index=this.Jk(a)):0<a.indexOf(":link")?(b.subId="oj-thematicmap-link",b.dataLayer=a.substring(0,a.indexOf(":")),b.index=this.Jk(a)):"tooltip"==a&&(b.subId="oj-thematicmap-tooltip");return b},Jf:function(){var a=this._super();a.push("oj-thematicmap");return a},Ej:function(){var a=this._super();a["oj-dvtbase oj-thematicmap"]=
{path:"animationDuration",property:"animation-duration"};a["oj-thematicmap-arealayer"]=[{path:"styleDefaults/areaStyle",property:"CSS_BACKGROUND_PROPERTIES"},{path:"styleDefaults/labelStyle",property:"CSS_TEXT_PROPERTIES"}];a["oj-thematicmap-area"]={path:"styleDefaults/dataAreaDefaults/borderColor",property:"border-top-color"};a["oj-thematicmap-area oj-hover"]={path:"styleDefaults/dataAreaDefaults/hoverColor",property:"border-top-color"};a["oj-thematicmap-area oj-selected"]=[{path:"styleDefaults/dataAreaDefaults/selectedInnerColor",
property:"border-top-color"},{path:"styleDefaults/dataAreaDefaults/selectedOuterColor",property:"border-bottom-color"}];a["oj-thematicmap-marker"]=[{path:"styleDefaults/dataMarkerDefaults/labelStyle",property:"CSS_TEXT_PROPERTIES"},{path:"styleDefaults/dataMarkerDefaults/color",property:"background-color"},{path:"styleDefaults/dataMarkerDefaults/opacity",property:"opacity"},{path:"styleDefaults/dataMarkerDefaults/borderColor",property:"border-top-color"}];a["oj-thematicmap-link"]={path:"styleDefaults/linkDefaults/color",
property:"color"};a["oj-thematicmap-link oj-hover"]={path:"styleDefaults/linkDefaults/_hoverColor",property:"color"};a["oj-thematicmap-link oj-selected"]={path:"styleDefaults/linkDefaults/_selectedColor",property:"border-color"};return a},Fj:function(){return["load","optionChange"]},_setOptions:function(b,c){var d=Object.keys(b).length,g=b.areaLayers,l=this.options.areaLayers,m=b.pointDataLayers;if(1==d&&g&&l&&0<l.length)for(d=0;d<g.length;d++){var m=g[d],r=l[d],t=!0,s;for(s in m)"areaDataLayer"!=
s&&m[s]!=r[s]&&(t=t&&!1);t&&!a.b.ek(r.areaDataLayer,m.areaDataLayer)&&this.Cy.push({options:m.areaDataLayer,parentLayer:m.layer,isADL:!0})}else if(1==d&&m&&this.options.pointDataLayers&&0<this.options.pointDataLayers.length)for(d=0;d<m.length;d++)a.b.ek(this.options.pointDataLayers[d],m[d])||this.Cy.push({options:m[d],parentLayer:m[d].id,isADL:!1});this._super(b,c)},Sh:function(){this.O2();var b=this.options.areaLayers;if(this.options.basemap&&b&&!(1>b.length)){this.Yza();for(var c=0;c<this.ev.length;c++)if(!this.WD[this.ev[c]])return;
this.ev=[];this.EFa();var d=(c=this.options.tooltip)?c.renderer:null;d&&(this.options._tooltip=function(b){var c=b.tooltip;try{return d(b)||c}catch(e){return a.t.warn("Showing default tooltip. "+e),c}});if(b)for(c=0;c<b.length;c++){var g=b[c].areaDataLayer;if(g){var l=g._templateRenderer;l&&(g.renderer=this.VJ(l,g.markers))}}if(b=this.options.pointDataLayers)for(c=0;c<b.length;c++)(g=b[c])&&(l=g._templateRenderer)&&(g.renderer=this.VJ(l,g.markers));this.options._contextHandler=this.jT();if(this.w$&&
0<this.Cy.length){if(this.bg.isReadyToRender()){for(c=0;c<this.Cy.length;c++)l=this.Cy[c],this.xa.updateLayer(l.options,l.parentLayer,l.isADL);this.Cy=[]}}else this._super(),this.w$=!0;this._trigger("load",null,null)}},VJ:function(a){var b=this;return function(c){var d=document.createElement("div");d.style.display="none";d.UC=b.bg;b.element.append(d);a({parentElement:d,data:c.data});return(c=d.children[0])?"http://www.w3.org/2000/svg"===c.namespaceURI?(d.removeChild(c),g(d).remove(),c):b.VB(c):null}},
jT:function(){var b=this;return function(c,d,g,l,m){return{component:a.Components.Yc(b.element),parentElement:c,rootElement:d,data:g,state:l,previousState:m,id:g.id,label:g.label,color:g.color,location:g.location,x:g.x,y:g.y}}},renderDefaultHover:function(a){a.previousState&&a.state.hovered==a.previousState.hovered||this.xa.processDefaultHoverEffect(a.id,a.state.hovered)},renderDefaultSelection:function(a){a.previousState&&a.state.selected==a.previousState.selected||this.xa.processDefaultSelectionEffect(a.id,
a.state.selected)},renderDefaultFocus:function(a){a.previousState&&a.state.focused==a.previousState.focused||this.xa.processDefaultFocusEffect(a.id,a.state.focused)},Yza:function(){var b=this.options.basemap;if(b){var c=a.fa.hj();c!==this.f6&&(this.f6=c,this.WD=[]);var d=this.options.areaLayers;if(d)for(var g=0;g<d.length;g++){var l=d[g].layer;l&&this.raa(b,l,c)}d=this.options.pointDataLayers;!this.options.mapProvider&&d&&0<d.length&&this.raa(b,"cities",c)}},uaa:function(b,c){if(!this.WD[b]){var d=
this,k=g.getScript(a.fa.gb(b),function(){d.WD[b]=!0;d.Sh()});c&&k.fail(function(){d.WD[b]=!0;d.Sh()})}},raa:function(b,c,g){var k=!0;try{k=0<Object.keys(d.DvtBaseMapManager.getLayerIds(b,c)).length}catch(l){k=!1}k||((k=this.options.mapProvider)?a.jb.MHa(b,c,k):(k=this.A4+"ojthematicmap-"+b+"-"+c+".js",-1==this.ev.indexOf(k)&&(this.ev.push(k),this.uaa(k,!1))));if(-1===g.indexOf("en"))for(k=g.toLowerCase().split("-"),g=[k[0]],1<k.length&&g.unshift(k[0]+"-"+k[1]),2<k.length&&g.unshift(k[0]+"-"+k[2],
k[0]+"-"+k[1]+"-"+k[2]),b=b.charAt(0).toUpperCase()+b.slice(1),c=c.charAt(0).toUpperCase()+c.slice(1),b=this.A4+"resourceBundles/"+b+c+"Bundle_",c=0;c<g.length;c++)if(this.Xda[g[c]]){b=b+this.Xda[g[c]]+".js";-1==this.ev.indexOf(b)&&(this.ev.push(b),this.uaa(b,!0));break}},El:function(a){if("selection"===a.type){var b={},c=a.clientId;b[c]=a.selection;if(this.options.selection)for(var d in this.options.selection)c!==d&&(b[d]=this.options.selection[d]);this.fe("selection",b)}else this._super(a)},Ti:function(){var a=
this.options.translations,b=this._super();b["DvtUtilBundle.THEMATIC_MAP"]=a.componentName;return b},EFa:function(){var a=this.options.selection;if(a){var b=this.options.pointDataLayers;if(b)for(var c=0;c<b.length;c++)a[b[c].id]&&(b[c].selection=a[b[c].id]);if(b=this.options.areaLayers)for(c=0;c<b.length;c++){var d=b[c].areaDataLayer;d&&a[d.id]&&(d.selection=a[d.id])}}},getArea:function(a,b){var c=this.xa.getAutomation().getData(a,"area",b);this.Ri(c);return c},getMarker:function(a,b){var c=this.xa.getAutomation().getData(a,
"marker",b);this.Ri(c);return c},getLink:function(a,b){var c=this.xa.getAutomation().getData(a,"link",b);this.Ri(c);return c},getContextByNode:function(a){return(a=this.getSubIdByNode(a))&&"oj-thematicmap-tooltip"!==a.subId?a:null},Ik:function(){return{areaLayers:["areaDataLayer/areas","areaDataLayer/markers"],pointDataLayers:["markers","links"]}},i2:function(a){var b=this.options.basemap;a=a.layer?a.layer:"cities";return{basemap:b,layer:a,ids:d.DvtBaseMapManager.getLayerIds(b,a)}}});a.jb={};a.jb.xH=
"DvtBaseMapManager";a.jb.L3="_UNPROCESSED_MAPS";a.jb.mq="type";a.jb.$ma="geometry";a.jb.vma="coordinates";a.jb.Wma="features";a.jb.koa="properties";a.jb.Yoa="FeatureCollection";a.jb.JMa="GeometryCollection";a.jb.Xoa="Feature";a.jb.K3="Polygon";a.jb.J3="MultiPolygon";a.jb.Fl="id";a.jb.Foa="shortLabel";a.jb.yna="longLabel";a.jb.MHa=function(b,c,d){var g={},l={},m=d.geo,r=d.propertiesKeys||{};d=m[a.jb.mq];if(d===a.jb.Yoa)m[a.jb.Wma].forEach(function(b){a.jb.ija(b,r,l,g)});else if(d===a.jb.Xoa)a.jb.ija(m,
r,l,g);else{a.t.error("GeoJSON type of "+d+" is not supported. Only Feature and FeatureCollection types are supported.");return}0===Object.keys(l).length?a.t.error("No valid Features found in GeoJSON."):(window[a.jb.xH]||(window[a.jb.xH]={},window[a.jb.xH][a.jb.L3]=[[],[],[]]),window[a.jb.xH][a.jb.L3][0].push([b,c,g,l,null,null,0]))};a.jb.ija=function(b,c,d,g){var l=b[a.jb.koa];b=b[a.jb.$ma];if(a.jb.TJa(b)){var m=l[c[a.jb.Fl]];if(m){var r=l[c[a.jb.Foa]];c=l[c[a.jb.yna]];if(r||c)g[m]=[r,c];d[m]=a.jb.NHa(b)}else a.t.warn("No 'id' value found in the mapProvider.propertiesKey object. A Feature's 'properties' object must have an id in the field specified by the mapProvider.propertiesKey.id value.")}else a.t.warn("A geometry of type "+
b[a.jb.mq]+" is not supported and will be skipped.")};a.jb.TJa=function(b){b=b[a.jb.mq];return b===a.jb.K3||b===a.jb.J3?!0:!1};a.jb.NHa=function(b){var c="",d=b[a.jb.mq];b=b[a.jb.vma];d===a.jb.K3?c=a.jb.nja(b):d===a.jb.J3&&b.forEach(function(b){c+=a.jb.nja(b)});return c};a.jb.nja=function(b){var c="";b.forEach(function(b){c+=a.jb.YJa(b)});return c};a.jb.YJa=function(a){var b,c,d,g="M";a&&a.forEach(function(a){var e=a[0];a=-a[1];if("M"===g)c=e,d=a,g="x",b="M"+e+" "+a;else{var t=e-c,s=a-d;if("l"==g){if(c==
e){g="v";d=a;b=b+g+s;return}if(d==a){g="h";c=e;b=b+g+t;return}b=b+" "+t+" "+s}else g="l",b=b+"l"+t+" "+s;c=e;d=a}});return b+"Z"};a.Components.Xa("ojThematicMap","dvtBaseComponent",{properties:{animationDuration:{type:"number"},animationOnDisplay:{type:"string"},animationOnMapChange:{type:"string"},areaLayers:{type:"Array\x3cobject\x3e"},basemap:{type:"string"},hiddenCategories:{type:"Array\x3cstring\x3e"},highlightedCategories:{type:"Array\x3cstring\x3e"},highlightMatch:{type:"string"},hoverBehavior:{type:"string"},
initialZooming:{type:"string"},mapProvider:{type:"object"},markerZoomBehavior:{type:"string"},maxZoom:{type:"number"},panning:{type:"string"},pointDataLayers:{type:"Array\x3cobject\x3e"},selection:{type:"object"},styleDefaults:{type:"object"},tooltip:{type:"object"},tooltipDisplay:{type:"string"},touchResponse:{type:"string"},zooming:{type:"string"}},methods:{getArea:{},getContextByNode:{},getLink:{},getMarker:{},renderDefaultFocus:{},renderDefaultHover:{},renderDefaultSelection:{}},extension:{_widgetName:"ojThematicMap"}});
a.Components.register("oj-thematic-map",a.Components.getMetadata("ojThematicMap"))});